package com.gss.plugin.oauth2.handler;

import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.TokenEnhancer;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: DYang
 * @since: 2023/8/21
 * @description: jwt增强器
 */
public class JwtTokenEnhancer implements TokenEnhancer {

    @Override
    public OAuth2AccessToken enhance(OAuth2AccessToken accessToken, OAuth2Authentication authentication) {
        Map<String,Object> infoMap = new HashMap<>();
        infoMap.put("version","0.0.1");

        ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(infoMap);

        return accessToken;
    }
}
